package com.woowc.cn.config.mb;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.context.annotation.Configuration;

import java.time.LocalDateTime;

/**
 * @version V1.0.0
 * @ClassName: {@link MyMetaObjectHandler}
 * @Description: 元数据处理器
 * @author: Lanzhou
 * @date: 2020/12/7 14:28
 * @Copyright:2020 All rights reserved.
 */
@Configuration
public class MyMetaObjectHandler implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        setFieldValByName("createBy", "10000", metaObject);
        setFieldValByName("createTime", LocalDateTime.now(), metaObject);
        setFieldValByName("delete", false, metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        setFieldValByName("updateBy", "10000", metaObject);
        setFieldValByName("updateTime", LocalDateTime.now(), metaObject);
    }

}
